#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> arr(n);
  for (auto &x : arr) scanf("%d", &x);
  nth_element(arr.begin(), arr.begin() + k, arr.end());
  cout << arr[k] << endl;
}